package com.yunze.apiCommon.upstreamAPI.ZY_ZhiShu;


import com.yunze.apiCommon.utils.MD5Util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 中翼 智树 系统 API 接口
 */
public class ZY_ZhiShu_Api {




	//构造赋值
	public ZY_ZhiShu_Api(Map<String, Object> init_map){

		account = init_map.get("cd_username").toString();
		password = init_map.get("cd_pwd").toString();
		agentId = init_map.get("cd_key").toString();


	}

	// 服务器请求地址     http://wx.e114.xin:9006/selfapi/zy-api/v1.0
	protected  static String server_Ip = "http://wx.e114.xin:9006/selfapi/zy-api/v1.0";
	// user_id
	public static String account = null;
	//版本号
	public static String version = "1.0";
	// 秘钥key
	public static String accessKey = null;
	//秘钥密码
	public static String password= null;
	//代理ID
	public static String agentId= null;


	// 配置调用的名称
	protected static String Config_name = "";



	public static String getSign(Map<String,Object> map,String key){
		List<String> list=new ArrayList<>(map.keySet());
       /* for (int i = 0; i < list.size(); i++) {
        	//System.out.println(list.get(i));
		}*/
		Collections.sort(list);
		////System.out.println("后----");
       /* for (int i = 0; i < list.size(); i++) {
        	//System.out.println(list.get(i));
		}*/
		StringBuffer sb=new StringBuffer();
		for(int i=0;i<list.size();i++){
			String k =list.get(i);
			String v=(String )map.get(k);
			sb.append(k).append("=").append(v).append("&");
		}
		String signstr=sb.append("key=").append(key).toString();
		String sign = MD5Util.MD5Encode(signstr).toUpperCase();
		return sign;
	}

}
